﻿using System;
using System.Linq;
using AvaloniaEdit.CodeCompletion;
using MarkdownRow.Assets;

namespace MarkdownRow.Edit.CompletionData;

public static class CompletionDataList
{
      
    public static ICompletionData[] Trigger(string s,Doc doc)
    {
        if (s is "*" or ">" or "-" or "`" or "%" || int.TryParse(s, out _))
            return doc.Font.Select(x => x.ToFont() as ICompletionData).ToArray();
        if(s is "/")
            return doc.Paragraph.Select(x => x.ToParagraph() as ICompletionData).ToArray();
        return Array.Empty<ICompletionData>();
    }
    public static UsingCompletion ToUsing(this DocItem item) => new(item);

    public static FontCompletion ToFont(this DocItem item) => new(item);

    public static ParagraphCompletion ToParagraph(this DocItem item) => new(item);
}